<template>
  <div class="container">
    <div class="title">
      <span>信息设置</span>
    </div>
    <el-divider></el-divider>
    <el-form label-width="180px">
      <div class="wrap">
        <el-form-item label="会员权益说明">
          <div class="lin-wrap">
            <el-input type="textarea" v-model="member_msg" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="会员上墙支付费用">
          <div class="lin-wrap">
            <el-input type="number" v-model="user_auth_price" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="甜茶币设置参数">
        </el-form-item>
<!--        <el-form-item label="隐私说明">-->
<!--          <div class="lin-wrap">-->
<!--            <tinymce :defaultContent="privacy" @change="change" />-->
<!--          </div>-->
<!--        </el-form-item>-->
        <el-form-item label="用户认证">
          <div class="lin-wrap">
            <el-input type="number" v-model="user_auth_currency" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="隐私设置">
          <div class="lin-wrap">
            <el-input type="number" v-model="user_privacy_currency" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="上墙">
          <div class="lin-wrap">
            <el-input type="number" v-model="up_wall_currency" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="登录">
          <div class="lin-wrap">
            <el-input type="number" v-model="login_currency" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="点赞别人名片">
          <div class="lin-wrap">
            <el-input type="number" v-model="zan_currency" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="分享别人名片">
          <div class="lin-wrap">
            <el-input type="number" v-model="share_currency" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="邀请1-2人，每人">
          <div class="lin-wrap">
            <el-input type="number" v-model="invite_currency" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="邀请3-5人，每人">
          <div class="lin-wrap">
            <el-input type="number" v-model="invite_currency_one" ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="5人以上，每5人">
          <div class="lin-wrap">
            <el-input type="number" v-model="invite_currency_two" ></el-input>
          </div>
        </el-form-item>
        <el-form-item class="submit">
          <el-button type="primary" @click="createData()">保 存</el-button>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import System from '@/models/system'
// import Tinymce from '@/components/base/tinymce'

export default {
  components: {
    // Tinymce,
  },
  data() {
    return {
      privacy: '',
      member_msg: '',
      user_auth_price: '',
      user_auth_currency: '',
      user_privacy_currency: '',
      up_wall_currency: '',
      login_currency: '',
      zan_currency: '',
      share_currency: '',
      invite_currency: '',
      invite_currency_one: '',
      invite_currency_two: '',
    }
  },
  mounted() {
    this.getInfo()
  },
  methods: {
    async getInfo() {
      const info = await System.getSystem()
      this.privacy = info.privacy
      this.member_msg = info.member_msg
      this.user_auth_price = info.user_auth_price
      this.user_auth_currency = info.user_auth_currency
      this.user_privacy_currency = info.user_privacy_currency
      this.up_wall_currency = info.up_wall_currency
      this.login_currency = info.login_currency
      this.zan_currency = info.zan_currency
      this.share_currency = info.share_currency
      this.invite_currency = info.invite_currency
      this.invite_currency_one = info.invite_currency_one
      this.invite_currency_two = info.invite_currency_two
    },
    async createData() {
      const self = this
      const info = {
        privacy: self.privacy,
        member_msg: self.member_msg,
        user_auth_price: self.user_auth_price,
        user_auth_currency: self.user_auth_currency,
        user_privacy_currency: self.user_privacy_currency,
        up_wall_currency: self.up_wall_currency,
        login_currency: self.login_currency,
        zan_currency: self.zan_currency,
        share_currency: self.share_currency,
        invite_currency: self.invite_currency,
        invite_currency_one: self.invite_currency_one,
        invite_currency_two: self.invite_currency_two,
      }
      const res = await System.updateSystem(info)
      if (res.error_code === 0) {
        this.$message.success(`${res.msg}`)
        this.getInfo()
      }
    },
    change(val) {
      this.privacy = val
    },
    changeOne(val) {
      this.advertisement = val
    },
  },
}
</script>

<style lang="scss" scoped>
.el-divider--horizontal {
  margin: 0;
}

.container {
  .title {
    height: 59px;
    line-height: 59px;
    color: $parent-title-color;
    font-size: 16px;
    font-weight: 500;
    text-indent: 40px;

    .back {
      float: right;
      margin-right: 40px;
      cursor: pointer;
    }
  }

  .wrap {
    padding: 20px;
  }

  .submit {
    float: left;
  }
}
</style>
